﻿using Customer.API.Applcation.Command.RecordedCommand;
using Customer.Infrstructre.ProcurementManager;
using MediatR;

namespace Customer.API.Applcation.CommandHandlers.RecordedCommand
{
    public class RecordedAddCommandHandler : IRequestHandler<RecordedAddCommand, int>
    {

        IProcureProductRepository pRep;

        public RecordedAddCommandHandler(IProcureProductRepository pRep)
        {
            this.pRep = pRep;
        }


        public async Task<int> Handle(RecordedAddCommand request, CancellationToken cancellationToken)
        {
            var res = await pRep.GetModelAsync(request.ProcureProductId);
            res.IsRecorded = request.IsRecorded;
            return await pRep.Update(res);

        }
    }
}
